#!/usr/bin/env bash
# Copyright (c) 2020 The Toltec Contributors
# SPDX-License-Identifier: MIT

pkgnames=(puzzles)
timestamp=2021-03-04T14:03-08:00
maintainer="Mattéo Delabre <spam@delab.re>"
_ver=0.2.4
pkgver=${_ver}-4
license=MIT
pkgdesc="Simon Tatham's Puzzle Package"
url="https://github.com/mrichards42/remarkable_puzzles"
section="games"
makedepends=(build:git)
flags=(patch_rm2fb)

image=python:v2.3.2
source=(
    "https://github.com/mrichards42/remarkable_puzzles/releases/download/v${pkgver%-*}/puzzles-source.tar.gz"
    puzzles.draft
)
sha256sums=(
    ae00474f6b1f7ced13bd6b1f18ff57b583fcd66c587a5180e87af997768345ff
    SKIP
)

build() {
    pip3 install okp

    # do the build
    make puzzles ARCH=rm BUILD=release RMP_VERSION="${_ver}"
}

package() {
    install -d "$pkgdir"/opt/etc/{draft,puzzles,puzzles/save}
    install -D -m 755 "$srcdir"/build/release/puzzles "$pkgdir"/opt/bin/puzzles
    install -D -m 644 "$srcdir"/puzzles.draft "$pkgdir"/opt/etc/draft/
    install -D -m 644 "$srcdir"/config/* -t "$pkgdir"/opt/etc/puzzles/config/
    install -D -m 644 "$srcdir"/help/* -t "$pkgdir"/opt/etc/puzzles/help/
    install -D -m 644 "$srcdir"/icons/* -t "$pkgdir"/opt/etc/puzzles/icons/
}
